<template>
  <div>
    <el-table
      :data="tableData"
      stripe
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        type="selection"
        width="55"
        v-if="!ischeck"
      >
      </el-table-column>
      <el-table-column
        type="index"
        width="50"
      >
      </el-table-column>
      <el-table-column
        prop="hash.username"
        label="人员姓名"
      >
      </el-table-column>
      <el-table-column
        prop="hash.cardnum"
        label="证书编号"
      >
      </el-table-column>
      <el-table-column
        prop="hash.icnum"
        label="IC卡号"
      >
      </el-table-column>
      <el-table-column
        prop="hash.cardtypename"
        label="人员类别"
      >
      </el-table-column>
      <el-table-column
        prop="hash.occupation_type_name"
        label="职业领域"
      >
      </el-table-column>
      <el-table-column
        prop="hash.position_type_name"
        label="从业岗位"
      >
      </el-table-column>
      <el-table-column
        prop="hash.starttime"
        label="开始时间"
      >
      </el-table-column>
      <el-table-column
        prop="hash.validtime"
        label="有效期"
      >
      </el-table-column>
      <el-table-column label="附件">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" @click="checkfilink(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      v-if="!ischeck"
      @current-change="handleCurrentChange"
      :currentPage.sync="pagobj.currentPage3"
      :pageSize="pagobj.pagesize"
      layout="total, prev, pager, next"
      :total="pagobj.total"
      style="margin:20px 0;text-align:center"
    >
    </el-pagination>
    <el-dialog title="附件信息" :visible.sync="dialogVisible" width="40%" appendToBody>
      <el-form labelWidth="150px">
    <el-table
      :data="flinklist"
      stripe
      style="width: 100%"
    >
      <el-table-column type="index" width="50" label="序号"></el-table-column>
      <el-table-column prop="hash.filename" label="附件名"></el-table-column>
      <el-table-column label="附件">
        <template slot-scope="scope">
          <a :href="scope.row.hash.fileurl" download="" target="_Blank">下 载</a>
        </template>
      </el-table-column>
    </el-table>
        <el-form-item>
          <div>&nbsp;</div>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ts: this.newStore(),
      dialogVisible: false,
      flinklist: [], // 拿到的附件数据
    };
  },
  props: {
    tableData: {
      type: Array,
      required: true,
    },
    pagobj: {
      type: Object,
      required: true,
    },
    ischeck: Boolean,
  },
  methods: {
    // 编辑
    checkfilink(item) {
      // console.log(item, "00000");
      const req = {
        handle: '0E56125B90D2898ACAD2C3968249185CCD3A43E9777C4E90',
        filetype: 'positioncard',
        mainid: item.hash.id,
      };
      this.spost(this.ts, "/mainservlet", req).then(ts => {
        if (ts.d.sflag == "success") {
          this.flinklist=ts.d.data.operation1
          // console.log(ts.d.data, "0909");
          this.dialogVisible = true;
        }
      });
    },
    handleSelectionChange(val){
      // console.log(val,'888');
      this.$emit('itemvals',val)
    },
    handleCurrentChange() {
      this.$parent.getlicenselist();
    },
    handleRemove(file, fileList) {
      // console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible2 = true;
    },
  },
};
</script>

<style>

</style>
